using RockHopper.Common.Commanding;
using RockHopper.Common.ViewModel;

namespace RockHopper.TrainingCalculator.WinRT.ViewModel
{
    public abstract class PopupViewModel : ViewModelBase
    {
        private bool isOpen;

        protected PopupViewModel()
        {
            PopupCommand = new DelegateCommand(Popup);
            CloseCommand = new DelegateCommand(OnCancelClick);
        }

        public abstract string Label { get; }

        public DelegateCommand PopupCommand { get; private set; }

        public DelegateCommand CloseCommand { get; private set; }

        public bool IsOpen
        {
            get
            {
                return isOpen;
            }
            set
            {
                isOpen = value;
                OnPropertyChanged("IsOpen");
            }
        }

        public void Popup()
        {
            IsOpen = true;
        }

        protected void OnCancelClick()
        {
            IsOpen = false;
        }
    }
}